<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<html>
<head>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<base href="<%=basePath%>">
  <title>new record</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="css/bootstrap.css">
  <link rel="stylesheet" href="css/record/new.css">
  <link rel="stylesheet" href="css/record/show.css">
  <script src="js/jquery/jquery-2.1.4.min.js"></script>
 <link href="js/ueditor/third-party/SyntaxHighlighter/shCoreDefault.css" rel="stylesheet" type="text/css" />
  <script type="text/javascript" src="js/ueditor/third-party/SyntaxHighlighter/shCore.js"></script>
  <script type="text/javascript">
  SyntaxHighlighter.all();
  </script>

</head>
<body>
<label id="rec_id" style="display: none;">${recordobj.id}</label>
<div id="container">
    <div id="head_div" style="height:55px">
    	<nav class="navbar navbar-default" role="navigation">
   <div class="navbar-header">
      <a class="navbar-brand nav-logoname" href="record">EasyNote</a>
   </div>
<!--    <div class="navbar-header">
   <a class="navbar-brand nav-logoname" href="sss">ssssssssssssssssss</a>
   </div>
 -->   <div>

       <label class="navbar-text nav-time">2015-10-17 12:23:12</label>
   </div>
</nav>
    </div>
    <div>
		<div id="left_div"></div>
		<div id="center_div">
		    <h4 class="title"><label id="rec_title">${recordobj.title}</label><br><small class="small-title">Author:leo    Create time:${createtime}  查看次数:0
          评论数:0</small><small class="small-title">${recordobj.tag}</small></h4>

          <label class="action_icon"></label>
          <img class="record_modify" src="image/icon/page_edit_32.ico" onclick="updateRecord()" style="cursor:pointer;"></img><img class="record_delete" src="image/icon/Delete.ico" onclick="DeleteRecord()" style="cursor:pointer;"></img>
          <img class="record_commit" src="image/icon/OK.ico" onclick="commitupdate()" style="cursor:pointer;"></img>
          <img class="record_cancel" src="image/icon/cancel.ico" onclick="updatecancel()" style="cursor:pointer;"></img>

          <br>
		    <hr>	    	      
 			<div id="div_content" style="" class="content">
 				${recordobj.content}
 			</div>

 			 <script id="editor" type="text/plain" style="width:97%;height:500px;margin-left:4%;"></script>

 			<hr>		    
<!--  			<span class="label label-default mctag" style="width: 240px;">默认标签</span> -->
		</div>
		<div id="right_div"></div>
	</div>	
	<div id="foot_div"></div>
</div>
</body>
    <!-- 配置文件 -->
    <script type="text/javascript" src="js/ueditor/ueditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="js/ueditor/ueditor.all.js"></script>
    <!-- 实例化编辑器 -->
    <script type="text/javascript">
        UE.getEditor('editor');
        $("#editor").hide();
        $("#commitUpdate").hide();
    </script>
    <script type="text/javascript">




      function DeleteRecord(){

              var obj=new Object();
      
              obj.id=$("#rec_id").html();
          $.post("/record/delete",obj,function(data){
         

          	if(data.code=="1")
          	{
          		self.location='/record'; 
        
          	}

        
        //window.location.reload();
          });
      }
    	
    	function updateRecord()
    	{
            $("#editor").show();
    		UE.getEditor('editor').setContent($("#div_content").html());
    		$("#div_content").hide();
    		 $("#commitUpdate").show();
    	$(".record_commit").show();
    	$(".record_cancel").show();
    	$(".record_modify").hide();
    	}
    	function commitupdate(){

    	 $("#editor").hide();
    	 $("#div_content").show();
    	  $(".record_commit").hide();
    	$(".record_cancel").hide();
    	$(".record_modify").show();

    	var obj=new Object();
			obj.title=$("#rec_title").html();
			obj.id=$("#rec_id").html();
			obj.content=UE.getEditor('editor').getContent();
			$("#div_content").html(obj.content);
			
			obj.simpletext=UE.getEditor('editor').getPlainTxt();
			obj.tag=$("#ipt_tags").val();
			$.post("/record/update",obj,function(data){
				
				//window.location.reload();
			});
			//window.location.reload();
    	}

    	function updatecancel(){
    		$("#editor").hide();
    		$("#div_content").show();
    		$(".record_commit").hide();
    	    $(".record_cancel").hide();
    	    $(".record_modify").show();

    	}
    	$(".record_commit").hide();
    	$(".record_cancel").hide();

        if($(document).height()>1000)
        {
			$('#container').css('height',$(document).height());
			$('#left_div').css('height',$(document).height());
			$('#center_div').css('height',$(document).height());
			$('#right_div').css('height',$(document).height());
    	}

    </script>
</html>
